<template>
	<view class="home">
		<!-- 历史记录 -->
		<view class="historyBox"
		 v-for="dataList in dataList" :key="dataList._id" >
			<!-- 历史记录头部 -->
			<view class="historyItem"
			@click="goQuestionsDetail(`${dataList.qOrder}`,`${dataList.subject_id}`,`${dataList.Chapterid}`)">
				<view class="historyRow  border"
				 >
					<view class="historyTitle">
						{{dataList.subjectName}}
					</view>
						
					<view class="historyContent">
						{{dataList.ChapterName}}
					</view>
					—
					<view class="historyContent">
						第{{dataList.qOrder}}题
					</view>
				</view>
				<!-- 时间戳 -->
				<view class="time">
					做题时间:{{$u.timeFormat(dataList.historyCreateTime, 'yyyy年mm月dd日 hh时MM分')}}
				</view>
				
				
			</view>
			
			
		</view>
	</view>
</template>

<script>
	const userInfo = uniCloud.importObject("userInfo", {
		customUI: true // 取消自动展示的交互提示界面
	}); //导入用户信息的云对象
	const db = uniCloud.database();
	
	export default {
		data() {
			return {
				uid:0,
				dataList:[] ,//保存用户错题记录数据
			};
		},
		onLoad() {
			this.getData();
		},
		methods:{
			//获取错题
			async getData(){
				this.uid = uniCloud.getCurrentUserInfo().uid;
				const wrongData = db.collection("history_person").where({
					uid:this.uid,
					optionResType:false
				})
				.orderBy("historyCreateTime","asc")
				.get();
				wrongData.then(res=>{
					console.log("wrongData",res);
					this.dataList = res.result.data;
					console.log("dataList", this.dataList);
				})
				
			},
			//点击历史记录跳转
			goQuestionsDetail(qOrder,subject_id,chapterid){
				uni.navigateTo({
					url:"/pages/questionDetail/questionDetail?uid="+this.uid +"&qOrder="+qOrder+"&cid="+subject_id+"&chapterId="+chapterid+"&mode="+"nomal"
				})
			}

		}
	}
</script>

<style lang="scss">
	$textSize: 28rpx;
	$radius:16rpx;
	
	view{
		box-sizing: border-box;
	}
	page{
		background-color: #f8f8f8;
	}
	.historyBoxNone {
		display: none;
	}
	
	.historyBox {
		margin: 12rpx;
		border-radius: $radius;
		background-color: #ffffff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 18rpx 18rpx;
		// border: 2rpx solid #85A9F0;
		.historyItem{
			display: flex;
			flex-direction: column;
			width:100%;
			.historyRow {
				padding-bottom: 12rpx;
				display: flex;
				align-items: center;
				
			}
				
			.historyTitle {
				font-size: 32rpx;
				font-weight: bold;
				padding-right: 12rpx;
			}
				
			.historyContent {
				font-size: 28rpx;
			}
			.time{
				padding-top: 8rpx;
				font-size: 18rpx;
				color: #888;
			}
			
		}
		.historyDel {
			padding-right: 18rpx;
		}

		
		
	}
	.border {
	  position: relative;
	}
	
	.border::after {
	  border-bottom: 1px solid #eee;
	  bottom: 0;
	  box-sizing: border-box;
	  content: " ";
	  left: 12rpx;
	  pointer-events: none;
	  position: absolute;
	  right: 12rpx;
	  transform: scaleY(.5);
	  transform-origin: center;
	}
</style>
